package com.bjpowerrnode.javase.string;
import java.util.Scanner;
public class StringTest06 {
    public static void main(String[] args) {
        //a = 97; a = 65
        Scanner scanner = new Scanner(System.in);
        String s1 = scanner.nextLine();
        String s2 = scanner.next();
        char[] char1 = s1.toCharArray();
        char c = s2.charAt(0);

        char temp = ' ';
        if(Character.isUpperCase(c)){
            temp = Character.toLowerCase(c);
        }
        if(Character.isLowerCase(c)){
            temp = Character.toUpperCase(c);
        }

        int count = 0;
        for(char c1 : char1){
            if(c1==c||c1==temp){
                count++;
            }
        }

        System.out.println(count);
    }

}
